<template>
  <div class="preview">
    <el-dialog
      :title="formData.title"
      :visible.sync="visible"
      width="60%"
      :before-close="handleClose"
    >
      <div class="dialog">
        <FormBoard :formData="formData" :type="3"/>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import FormBoard from './FormBoard'
export default {
  name: 'Preview',
  components: {
    FormBoard,
  },
  props: {
    formData: {
      default: () => {
        return {
          title: '',
          number: '',
          fields: [],
        }
      },
    },
    value: {
      type: Boolean,
      default: false,
    },
  },

  watch: {
    value (val) {
      this.visible = val
    }
  },

  data () {
    return {
      visible: false,
    }
  },
  methods: {
    handleClose () {
      this.$emit('input', false)
    },
    confirm () {
      this.handleClose()
    },
  },

  mounted () {
    if (this.value) {
      this.visible = this.value
    }
  },
}
</script>

<style lang="less" scoped>
/deep/ .el-dialog__header {
  padding: 0;
  padding: 10px 16px;
  font-size: 14px;
  color: #262A30;
  border: 1px solid #DBDFEB;
}

/deep/ .el-dialog__headerbtn{
  top: 10px;
}

</style>
